package com.cg;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

/**
 * completableFuture串行执行
 */
public class CompleteFutureTest05 {

    private static String action="";

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        System.out.println("主线程开始");
        CompletableFuture<String> future =
                CompletableFuture.supplyAsync(() -> {
                    System.out.println(Thread.currentThread().getName());
                    action="和朋友一起去次烧烤!!!! ";
                    return action;
                }).thenApply(string -> {
                    return  action+="到店里——>开始点烧烤！！";
                }).thenApply(String->{
                    return  action+="和朋友们次完烧烤，给女朋友带杯奶茶回去！！";
                });
        String str = future.get();
        System.out.println("主线程结束, 子线程的结果为:" + str);
    }

}
